home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************
-
- File: ListUtils.h
-
- Copyright © 1996, 1997, 1998 Apple Computer, Inc., All Rights Reserved
-
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- *************************************************************************************/
-
-
- #ifndef _LISTUTILS_H_
- #define _LISTUTILS_H_
-
- #ifndef __MACTYPES__
- #include <MacTypes.h>
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- /*
- ************************************************************************
- ** constants
- ************************************************************************
- */
- /* iteration directions */
- #define kListNotIterating 0
- #define kListIterateForward 1
- #define kListIterateBackward 2
-
- /* node add locations */
- #define kListDontAdd 0
- #define kListAddTail 1
- #define kListAddHead 2
-
- /*
- ************************************************************************
- ** data types
- ************************************************************************
- */
- typedef UInt32 ListIterationDirection;
- typedef UInt32 ListNodeAddLocation;
-
- typedef struct ListNode {
- struct ListNode *next;
- struct ListNode *prev;
- void *data;
- } ListNode;
-
- typedef struct List {
- ListNode *head;
- ListNode *tail;
- ListNode *curr;
- UInt32 iterationDirection;
- } List;
-
- /*
- ************************************************************************
- ** prototypes
- ************************************************************************
- */
- List *List_New( void );
- void List_Dispose( List *inList );
- void List_Initialize( List *inList );
-
- ListNode *List_NewNode( List *inList,
- ListNodeAddLocation inAddLocation );
- void List_DisposeNode( ListNode *inNode );
-
- ListNode *List_GetHead( List *inList );
- ListNode *List_GetTail( List *inList );
-
- void List_AddHead( List *inList, ListNode *inNode );
- void List_AddTail( List *inList, ListNode *inNode );
-
- void *List_RemoveHead( List *inList );
- void *List_RemoveTail( List *inList );
- void *List_RemoveNode( List *inList, ListNode *inNode );
- void *List_RemoveNodeByData( List *inList, void *inNodeData );
-
- ListIterationDirection List_GetIterationState( List *inList );
- Boolean List_BeginIteration( List *inList,
- ListIterationDirection inIterateDirection,
- Boolean inBlockWhileBusyFlag );
- void List_EndIteration( List *inList );
- void *List_Iterate( List *inList );
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* _LISTUTILS_H_ */